@extends('layouts.public')

@section('head')
    <link rel="stylesheet" href="{{cdn('js/plugins/webuploader/single.css')}}">
    <style>
        .items {
            margin-bottom: 15px;
        }
    </style>
@endsection

@section('bodyattr')class="gray-bg"@endsection

@section('body')
    <div class="wrapper wrapper-content">
        <div class="row m-b">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li><a href="{{route('admin.good.goods')}}">商品列表</a></li>
                        <li @if(!isset($user))class="active"@endif><a href="{{route('admin.good.goods.add')}}">新增</a>
                        </li>
                        @if(isset($user))
                            <li class="active"><a href="#">审核</a></li>
                        @endif
                    </ul>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form action="{{route('admin.good.goods.refund')}}" method="post"
                              class="form-horizontal ajaxForm">
                            <input type="hidden" name="id" value="{{$user->id or 0}}"/>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">商品名称</label>
                                <div class="col-sm-3">
                                    {{$user->title or ''}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">商品地址</label>
                                <div class="col-sm-3">
                                    {{$user->address or ''}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">店铺</label>
                                <div class="col-sm-3">


                                    @foreach ($shops as $shop)
                                        @if ($user->shop_id == $shop['id'])
                                            {{$shop['title']}}
                                        @endif
                                    @endforeach
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">所属分类</label>
                                <div class="col-sm-3">
                                    @foreach ($cates as $cate)

                                        @if ((isset($user->cate_id) ? $user->cate_id : '') == $cate['cate_id'])
                                            &nbsp;&nbsp;&nbsp;&nbsp;{{$cate['cate_name']}}
                                        @endif
                                    @endforeach

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">商品型号 </label>
                                {{--                                <div class="col-sm-6">--}}
                                {{--                                    <div class="btn btn-success" id="add_options">+</div>--}}
                                {{--                                </div>--}}

                                <div class="col-sm-8">
                                    @foreach(json_decode($user['sizes'],true) as $g)
                                        <div class="col-sm-6">
                                            {{$g['size_name']}}

                                        </div>
                                        <div class="col-sm-4">
                                            {{$g['size_num']}}
                                        </div>
                                    @endforeach
                                </div>


                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">商品图片</label>
                                <div class="col-sm-10" id="imgupload">
                                    {{--                                    <div id="filePicker">选择图片</div>--}}
                                    @if(isset($user) && $user->default_img != '')
                                        @foreach(explode(',',$user['default_img']) as $g)
                                            <div class="img-div">
                                                <img src="{{get_file_url($g)}}"/>

                                            </div>
                                        @endforeach
                                    @endif
                                    {{--                                    <input type="hidden" name="default_img" id="default_img" value="{{$user->default_img or ''}}"/>--}}
                                    {{--                                    <input type="hidden" name="file_id" id="file_id" value="0"/>--}}
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">商品详情</label>
                                <div class="col-sm-10">

                                    {!!$user->content !!}

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">评论</label>
                                <div class="col-sm-10">
                                    <div class="input-group m-t-xs-2">
                                        <input type="radio" name="is_comment" value="1" readonly
                                               @if ((isset($user->is_comment) ? $user->is_comment : '') != '0') checked="checked"@endif/>允许
                                        <input type="radio" name="is_comment" value="0" readonly
                                               @if ((isset($user->is_comment) ? $user->is_comment : '') == '0') checked="checked"@endif/>不允许
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">推荐</label>
                                <div class="col-sm-10">
                                    <div class="input-group m-t-xs-2">
                                        <input type="radio" name="is_recommend" value="1" readonly
                                               @if ((isset($user->is_recommend) ? $user->is_recommend : '') == '1') checked="checked"@endif/>推荐
                                        <input type="radio" name="is_recommend" value="0" readonly
                                               @if ((isset($user->is_recommend) ? $user->is_recommend : '') != '1') checked="checked"@endif/>不推荐
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否通过</label>
                                <div class="col-sm-10">
                                    <div class="input-group m-t-xs-2">
                                        <input type="radio" name="status" value="1"
                                               @if ((isset($user->status) ? $user->status : '') == '1') checked="checked"@endif/>是
                                        <input type="radio" name="status" value="2"
                                       @if ((isset($user->status) ? $user->status : '') != '1') checked=" checked"@endif
                                        />否
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">拒绝理由</label>
                                <div class="col-sm-10">
                                    <textarea class="form-control" cols="30" rows="10" name="refund_msg"></textarea>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">保存</button>
                                    <button class="btn btn-white" type="button" id="backBtn">返回</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script src="{{cdn('js/plugins/ueditor/ueditor.config.js')}}"></script>
    <script src="{{cdn('js/plugins/ueditor/ueditor.all.min.js')}}"></script>
    <script src="{{cdn('js/plugins/ueditor/lang/zh-cn/zh-cn.js')}}"></script>
    <script type="text/javascript">
        jQuery(function ($) {

            $('#add_options').click(function () {
                var str = '<div class="row items">\n' +
                    '                    <div class="col-sm-6">\n' +
                    '                    <input type="text"  class="form-control" name="size_name[]" placeholder="请输入商品型号">\n' +
                    '                    </div>\n' +
                    '                    <div class="col-sm-4">\n' +
                    '                    <input type="text"  class="form-control" name="size_num[]" placeholder="请输入商品数量">\n' +
                    '                    </div>\n' +
                    '                    <div class="btn btn-default des">-</div>\n' +
                    '                    </div>';
                $('#options').append(str);
                $('.des').click(function () {
                    $(this).parent().remove()
                })

            })
            $('.des').click(function () {
                $(this).parent().remove()
            })
        });
    </script>
    <script src="{{cdn('js/plugins/webuploader/webuploader.nolog.min.js')}}"></script>
    <script src="{{cdn('js/plugins/webuploader/webuploader_public.js')}}"></script>
    <script type="text/javascript">
        jQuery(function ($) {
            singleUpload({
                _token: '{{csrf_token()}}',
                type_key: 'FT_ARTICLE_IMG',
                item_id: '{{$user->id or 0}}',
                pick: 'filePicker',
                boxid: 'imgupload',
                file_path: 'default_img',
                file_id: 'file_id'
            });
            $('#imgupload').find('.img-div>span').click(function () {
                sUploadDel($(this), 'default_img');
            });
        });
    </script>
@endsection
